using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


/// <summary>
/// The JobDesignationCodeTableManager class is responsible for managing BO.JobDesignationCodeTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class JobDesignationCodeTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all JobDesignationCodeTable objects in the database.
/// </summary>
/// <returns>A list with all JobDesignationCodeTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static JobDesignationCodeTableList GetList(){
return JobDesignationCodeTableDB.GetList();
}

/// <summary>
/// Gets a single JobDesignationCodeTable from the database without its data.
/// </summary>
/// <param name="jobDesignationCode">The JobDesignationCode of the JobDesignationCodeTable in the database.</param>
/// <returns>A JobDesignationCodeTable object when the JobDesignationCode exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static JobDesignationCodeTable GetItem(Int16 jobDesignationCode){
return GetItem(jobDesignationCode, false);
}

/// <summary>
/// Gets a single JobDesignationCodeTable from the database.
/// </summary>
/// <param name="jobDesignationCode">The JobDesignationCode of the JobDesignationCodeTable in the database.</param>
/// <param name="getJobDesignationCodeTableRecords">Determines whether to load all associated JobDesignationCodeTable records as well.</param>
/// <returns>
/// A JobDesignationCodeTable object when the JobDesignationCode exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static JobDesignationCodeTable GetItem(Int16 jobDesignationCode, bool getJobDesignationCodeTableRecords)
{
JobDesignationCodeTable myJobDesignationCodeTable = JobDesignationCodeTableDB.GetItem(jobDesignationCode);
if (myJobDesignationCodeTable != null && getJobDesignationCodeTableRecords){
myJobDesignationCodeTable.teacherDesignationTables = TeacherDesignationTableDB.GetListByJobDesignationCode(jobDesignationCode);
}
return myJobDesignationCodeTable;
}

/// <summary>
/// Saves a JobDesignationCodeTable in the database.
/// </summary>
/// <param name="myJobDesignationCodeTable">The JobDesignationCodeTable instance to save.</param>
/// <returns>The new JobDesignationCode if the JobDesignationCodeTable is new in the database or the existing JobDesignationCode when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static Int16 Save(JobDesignationCodeTable myJobDesignationCodeTable)
{
using (TransactionScope myTransactionScope = new TransactionScope()){
    Int16 jobDesignationCodeTableJobDesignationCode = JobDesignationCodeTableDB.Save(myJobDesignationCodeTable);
foreach (TeacherDesignationTable myTeacherDesignationTable in myJobDesignationCodeTable.teacherDesignationTables){
myTeacherDesignationTable.JobDesignationCode = jobDesignationCodeTableJobDesignationCode;
TeacherDesignationTableDB.Save(myTeacherDesignationTable);
}

//  Assign the JobDesignationCodeTable its new (or existing JobDesignationCode).
myJobDesignationCodeTable.JobDesignationCode = jobDesignationCodeTableJobDesignationCode;

myTransactionScope.Complete();

return jobDesignationCodeTableJobDesignationCode;
}
}

/// <summary>
/// Deletes a JobDesignationCodeTable from the database.
/// </summary>
/// <param name="myJobDesignationCodeTable">The JobDesignationCodeTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(JobDesignationCodeTable myJobDesignationCodeTable){
return JobDesignationCodeTableDB.Delete(myJobDesignationCodeTable.JobDesignationCode);
}

#endregion

}

